var cube = {
    /**
     * 判断对象为空
     * @param obj
     * @returns {boolean}
     */
    isBlank: function (obj) {
        return obj === undefined || obj == null || obj === '';
    },
    /**
     * 判断对象不为空
     * @param obj
     * @returns {boolean}
     */
    isNotBlank: function (obj) {
        return !cube.isBlank(obj);
    },
    /**
     * 补0 方法
     * @param num
     * @param length
     * @returns {string}
     */
    digit: function (num, length) {
        var str = '';
        num = String(num);
        length = length || 2;
        for (var i = num.length; i < length; i++) {
            str += '0';
        }
        return num < Math.pow(10, length) ? str + (num | 0) : num;
    },
    /**
     * 时间格式化
     * @param time
     * @param format
     * @returns {*}
     */
    dateformatAll: function (time, format) {
        var that = this
            , date = new Date(time || new Date())
            , ymd = [
            that.digit(date.getFullYear(), 4)
            , that.digit(date.getMonth() + 1)
            , that.digit(date.getDate())
        ]
            , hms = [
            that.digit(date.getHours())
            , that.digit(date.getMinutes())
            , that.digit(date.getSeconds())
        ];

        format = format || 'yyyy-MM-dd HH:mm:ss';

        return format.replace(/yyyy/g, ymd[0])
            .replace(/MM/g, ymd[1])
            .replace(/dd/g, ymd[2])
            .replace(/HH/g, hms[0])
            .replace(/mm/g, hms[1])
            .replace(/ss/g, hms[2]);
    },
    /**
     * 列表转换日期函数
     * @param data
     * @returns {string}
     */
    convertDate: function (data) {
        var code = this.field;
        if (data[code] == 0 || cube.isBlank(data[code])) {
            return '-'
        }

        if (data[code].indexOf("T") != -1) {
            return cube.dateformatAll(new Date(data[code]).getTime(), "yyyy-MM-dd");
        } else {
            return cube.dateformatAll(new Date(data[code]), "yyyy-MM-dd");
        }
    },
    /**
     * 列表转换日期时间函数 yyyy-MM-dd hh:mm:ss
     * @param data
     * @returns {string}
     */
    convertDateTime: function (data) {
        var code = this.field;
        if (data[code] == 0 || cube.isBlank(data[code])) {
            return '-'
        }
        if (data[code].indexOf("T") != -1) {
            return layui.util.toDateString(new Date(data[code]).getTime(), "yyyy-MM-dd HH:mm:ss")
            //return cube.dateformatAll(new Date(data[code]).getTime());
        } else {
            return layui.util.toDateString(data[code], "yyyy-MM-dd HH:mm:ss")
            //return cube.dateformatAll(new Date(data[code]));
        }
    },

}